package cn.tj212.xiaoyin.util;

import org.apache.commons.codec.digest.DigestUtils;

public class MD5Util {

    private static final String salt="aljdljlfldjlauetnj";

    public static String md5(String pass){
        return DigestUtils.md5Hex(pass);
    }

    public static String inputPassFormPass(String inputPass){
        String str=salt.charAt(0)+salt.charAt(2)+inputPass+salt.charAt(5)+salt.charAt(4);
        return md5(str);
    }

    public static String formPassToDbPass(String formPass,String randomSalt){
        String str=salt.charAt(0)+salt.charAt(2)+formPass+salt.charAt(5)+salt.charAt(4);
        return md5(str);
    }

    public static String inputPassToDbPass(String inputPass,String dbSalt){
        String formPass=inputPassFormPass(inputPass);
        String dbPass=formPassToDbPass(formPass,dbSalt);
        return dbPass;
    }
}
